<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        #x1 {
            width: 100px;
            height: 100px;
            padding: 100px;
            background-color: #f00;
        }
    </style>
</head>

<body>
    <div id="x1">

    </div>
</body>
<script>
    var a = x1.offsetWidth;
    console.log(a);
    var b = x1.offsetHeight;
    console.log(b);
    x1.style.width = "300px"
</script>

</html>